<template>

 <div class="mod-config">
    <h2 style="text-align: center;">添加球队信息</h2>

    <el-steps :active="1" process-status="wait" align-center style="margin-bottom: 40px;">
      <el-step title="球队资料"/>
      <el-step title="球队常规赛基础数据"/>
      <el-step title="球队常规赛进阶数据"/>
    </el-steps>

    <el-form  :model="list" label-width="100px"
    width="100" :inline="true" class="demo-form-inline" style="margin-left:10%">
  <el-form-item label="球队名字">
    <el-input v-model="list.name"></el-input>
  </el-form-item>
  <el-form-item label="所在城市">
    <el-input v-model="list.city"></el-input>
  </el-form-item>
   <el-form-item label="球队老板">
    <el-input v-model="list.boss"></el-input>
  </el-form-item>
  <el-form-item label="所在赛区">
    <el-input v-model="list.division"></el-input>
  </el-form-item>
  <el-form-item label="创建时间">
    <el-input v-model="list.entryTime"></el-input>
  </el-form-item>
   <el-form-item label="球队主教练">
    <el-input v-model="list.coach"></el-input>
  </el-form-item>
   <el-form-item label="球队简介">
    <el-input v-model="list.introduction"></el-input>
  </el-form-item>
<el-form-item label="球队log" >
    <!-- <el-input v-model="list.cover"></el-input> -->
     <single-upload v-model="list.cover" :floder="this.floder"></single-upload>
  </el-form-item>
 
    <br>
     <el-form-item class="a">
            <el-button type="primary" @click="saveOrUpdate">保存并下一步</el-button>
        </el-form-item>
</el-form>
 </div>
</template>
<script>
import SingleUpload from "@/components/upload/singleUpload"
  export default {
    components:{SingleUpload},
    data() {
      return {
        floder:'team',
        list: { 
          name: '',
          city: '',
          boss: '',
          division: '',
          entryTime: '',
          coach: '',
          introduction: '',
          cover: ''
        }
      }
    },
    created(){
      if(this.$route.params.id){
        this.getinformationById()
      }
    },
    methods: {
     addinformation(){
          this.$http({
          url: this.$http.adornUrl('/team/teaminformation/save'),
          method: 'post',
          data:this.list
        }).then(({data}) => {
               this.$message({
                    type:'success',
                    message:'添加球队信息成功！'
                });
               this.$router.push({
                 path:'/team/team-add-basicdate/'+data.id
               });
        })
     },
     updateinformation(){
          this.$http({
          url: this.$http.adornUrl('/team/teaminformation/update'),
          method: 'post',
          data:this.list
        }).then(({data}) => {
               this.$message({
                    type:'success',
                    message:'修改球队信息成功！'
                });
               this.$router.push({
                 path:'/team/team-add-basicdate/'+this.$route.params.id
               });
        })
     },
      saveOrUpdate(){
            if(!this.$route.params.id){
                this.addinformation()
            }else{
                this.updateinformation()
            }
         
        },
    getinformationById(){
          this.$http({
          url: this.$http.adornUrl(`/team/teaminformation/info/${this.$route.params.id}`),
          method: 'post'
        }).then(({data}) => {
              this.list = data.teamInformation
        })
    }
  }
  }
</script>

<style>

  .el-input__inner{
      width: 300px;
    
  }
  .a{
      margin-left:40%
  }
</style>